package net.oschina.cordova.sharesdk;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
import org.json.JSONArray;
import org.json.JSONException;

import android.content.Context;
import android.util.Log;


public class DownLoadPlugin extends CordovaPlugin {
	private static final String TAG = "DownLoadPlugin";
	private Context mContext;

	@Override
	public void initialize(CordovaInterface cordova, CordovaWebView webView) {
		Log.v(TAG, "initialize");
		super.initialize(cordova, webView);
		mContext = cordova.getActivity();
	}

	@Override
	public boolean execute(String action, JSONArray args,
			CallbackContext callbackContext) throws JSONException {
		Log.v(TAG, "execute>>" + action + ",arg>>" + args.toString());
		System.out.println("DownLoadPlugin");
		
	
		if (action.equals("downloadpic")) {
			
//			Toast.makeText(cordova.getActivity(), "测试cordova参数Login",Toast.LENGTH_SHORT).show();
			
			System.out.println(args);
			String strs= args.getString(1);
			
			System.out.println(strs);
		    DownLoadPic dlp = new DownLoadPic();
			dlp.downFile(mContext, strs);
			
		} else if (action.equals("getAccountMessage")) {
//			getAccountMessage(callbackContext);
			
		}
		
		
		
	
		return true;
	}

}
